class Solution {
public:
    uint32_t reverseBits(uint32_t n)
    {
        uint32_t r = 0;
        uint32_t t = 0x00000001;
        for(int i = 0; i < 32; ++i) {
            uint32_t x = n & t;
            r = r | x;
            n>>=1;
            if(i<31){
                r<<=1;
            }
        }
        return r;
    }
};